#include<iostream>

using namespace std;

int main()
{
	int N, sum = 0, cards[100], count = 0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> cards[i];
		sum += cards[i];
	}
	int wanted = sum / N;
	for (int i = 0; i < N - 1; i++)
	{
		if (cards[i] == wanted) continue;
		cards[i + 1] -= wanted - cards[i];
		count++;
	}
	cout << count;
	return 0;
}